/*
 * ScopedAVPacket.h
 *
 *  Created on: 2018年7月6日
 *      Author: zhengboyuan
 */

#ifndef SCOPEDAVPACKET_H_
#define SCOPEDAVPACKET_H_

#include "Ffmpeg.h"

class ScopedAVPacket
{
public:
    ScopedAVPacket(AVPacket* pkt):
        m_pkt(pkt)
    {
    }

    virtual ~ScopedAVPacket()
    {
        release();
    }

    void release()
    {
        if (m_pkt)
        {
            av_packet_unref(m_pkt);
            m_pkt = NULL;
        }
    }

protected:
    AVPacket* m_pkt;
};


#endif /* SCOPEDAVPACKET_H_ */
